using System;
using System.Threading.Tasks;
using Autofac.Features.AttributeFilters;
using Microsoft.AspNetCore.Mvc;
using Umi.Web.Abstraction.Services;
using Umi.Web.Metadatas.Attributes;

namespace Umi.Web.Controller.Sample.Controllers
{
    /// <summary>
    /// 实例控制器
    /// </summary>
    [Route("/api/sample")]
    [Service(IsAsSelf = true)]
    public class SampleController : Microsoft.AspNetCore.Mvc.Controller
    {
        private readonly IMessageSender sender;

        public SampleController([KeyFilter("EmailSender")]IMessageSender sender)
        {
            this.sender = sender;
        }

        [HttpGet]
        public virtual async Task<string> Get()
        {
            await sender.SendMessage("vvxx007@qq.com", "测试", "测试邮件");
            return "Hello World";
        }
    }
}
